<?php

namespace App\Models\Mgt;

use Illuminate\Database\Eloquent\Model;

class Category extends Model  
{
	protected $table = 'mgt_categories';

	protected $guarded = array();

	public $timestamps = false;	


	public function children()
	{
		return $this->hasMany($this,'pid','id');
	}


	public function parent()
	{
		return $this->belongsTo($this,'pid','id');
	}

	public function scopeParents($query)
	{
		return $query->where('pid', 0);
	}
}